/**
 * Copyright (C)  2011  chen wei hua.
 * Permission is granted to copy, distribute and/or modify this document
 * under the terms of the GNU Free Documentation License, Version 2.0
 * or any later version published by the Free Software Foundation;
 * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 * A copy of the license is included in the section entitled "GNU Free Documentation License".
 */
package com.javaeye.order.dto;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import com.javaeye.common.dto.DTO;
import com.javaeye.common.util.DateUtils;

public class PurchaseOrder implements DTO {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 6894920169941893269L;

	private String id;
	
	private Date orderDate;
	
	private String customName;
	
	private int customId;
	
	private String contractNo;
	
	private Date expectOutDate;
	
	private double totleAmount;
	
	private String removeDetailIds;
	
	private int status;
	
	private Integer planMaterials;

	private Set<PurchaseOrderDetail> orderDetails = new HashSet<PurchaseOrderDetail>();

	public void addDetail(PurchaseOrderDetail detail) {
		detail.setOrder(this);
		orderDetails.add(detail);
	}
	
	public void removeDetail(PurchaseOrderDetail detail) {
		orderDetails.remove(detail);
		detail.setOrder(null);
	}
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Date getOrderDate() {
		return orderDate;
	}

	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}

	public String getCustomName() {
		return customName;
	}

	public void setCustomName(String customName) {
		this.customName = customName;
	}

	public int getCustomId() {
		return customId;
	}

	public void setCustomId(int customId) {
		this.customId = customId;
	}

	public String getContractNo() {
		return contractNo;
	}

	public void setContractNo(String contractNo) {
		this.contractNo = contractNo;
	}

	public Date getExpectOutDate() {
		return expectOutDate;
	}

	public void setExpectOutDate(Date expectOutDate) {
		this.expectOutDate = expectOutDate;
	}

	public double getTotleAmount() {
		return totleAmount;
	}

	public void setTotleAmount(double totleAmount) {
		this.totleAmount = totleAmount;
	}

	public Set<PurchaseOrderDetail> getOrderDetails() {
		return orderDetails;
	}

	public void setOrderDetails(Set<PurchaseOrderDetail> orderDetails) {
		this.orderDetails = orderDetails;
	}

	public void setRemoveDetailIds(String removeDetailIds) {
		this.removeDetailIds = removeDetailIds;
	}

	public String getRemoveDetailIds() {
		return removeDetailIds;
	}
	
	public boolean getOrderWarning() {
		Date NowDay = DateUtils.getDateFromNow(-1);
		Date afterNowFiveDay = DateUtils.getDateFromNow(5);
		return (expectOutDate.after(NowDay) && expectOutDate.before(afterNowFiveDay));
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getStatus() {
		return status;
	}

	public void setPlanMaterials(Integer planMaterials) {
		this.planMaterials = planMaterials;
	}

	public Integer getPlanMaterials() {
		return planMaterials;
	}
	
}
